﻿Public Class TrayectoriaMap

    Public Sub drawMap(ByVal _GpsPos As DotSpatial.Topology.Coordinate)


        'dibujar una elipse en la posición gps actual, utilizando el PaintEventArgs
        Dim g As Graphics = MainForm.Map1.CreateGraphics()
        Dim pen As Pen = New Pen(Color.FromArgb(128, 255, 0, 0), 3)
        'convertir la posición gps para asignar píxeles
        Dim ptGPSinPixels As System.Drawing.Point = MainForm.Map1.ProjToPixel(New DotSpatial.Topology.Coordinate(_GpsPos))
        g.DrawEllipse(pen, New Rectangle(ptGPSinPixels.X, ptGPSinPixels.Y, 5, 5))

        'Si se ha movido en el mapa se reaposiniona en la coordenada gps 
        If MainForm.Map1.ViewExtents.MaxX < _GpsPos.Y OrElse MainForm.Map1.ViewExtents.MinX > _GpsPos.X OrElse MainForm.Map1.ViewExtents.MaxY < _GpsPos.Y OrElse MainForm.Map1.ViewExtents.MinY > _GpsPos.X Then
            MainForm.Map1.ViewExtents.SetCenter(_GpsPos.X, _GpsPos.Y, MainForm.Map1.ViewExtents.Width, MainForm.Map1.ViewExtents.Height)
        End If
        MainForm.Map1.ResetBuffer()
        MainForm.Map1.Invalidate()



    End Sub
End Class
